package com.qiangqiang.combination;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by q on 2018/4/6.
 */
public class StudentCourse {

    private List<CourseInfo> parts;

    public StudentCourse() {
        parts=new ArrayList<CourseInfo>();
    }

    public void attach(CourseInfo info){
        if (info!=null){
            parts.add(info);
        }
    }
    public void detach(CourseInfo info){
        if (info!=null){
            parts.remove(info);
        }
    }
    public int getAllCredits() {
        int count=0;
        for (CourseInfo info:parts) {
            count+=info.getCredits();
        }
        return count;
    }
}
